<template>
	<view class="">
		<view class="pho" v-if="pic.length >= 1"><image :src="item.src" v-for="(item, index) in pic" @tap="preview(index)" mode="aspectFill"></image></view>
		<view class="nophotodetail" v-else>暂无照片</view>
		<navigation></navigation>
		<!-- loading 遮罩层 -->
		<loading v-if="loadflag"></loading>
	</view>
</template>

<script>
import navigation from '@/components/navigation/navigation.vue';
import loading from '@/components/loading/loading.vue';
export default {
	components: {
		navigation,
		loading
	},
	data() {
		return {
			pic: [],
			photodetail_id: '',
			page: '1',
			pic_list: [],
			loadflag: true,
		};
	},
	onLoad(options) {
		//  // console.log (options)
		this.photodetail_id = options.id;
	},
	mounted() {
		this.getphotodetail();
	},
	methods: {
		// 获取相册的照片信息
		getphotodetail() {
			this.ajax('active/activeAlbumPhoto', {
				data: {
					album_id: this.photodetail_id,
					page: this.page
				},
				success: res => {
					 // console.log (res);
					this.loadflag = false;
					this.pic = res.msg.data;
					var srclist = res.msg.data;
					srclist = srclist.forEach(e => {
						this.pic_list = this.pic_list.concat(e.src);
						 // console.log (this.pic_list);
					});
				}
			});
		},
		preview(key) {
			uni.previewImage({
				current: key,
				urls: this.pic_list,
				indicator: 'number',
				longPressActions: {
					itemList: ['发送给朋友', '保存图片', '收藏'],
					success: data => {
						 // console.log ('选中了第' + (data.tapIndex + 1) + '个按钮,第' + (data.index + 1) + '张图片');
					},
					fail: function(err) {
						 // console.log (err.errMsg);
					}
				}
			});
		}
	}
};
</script>

<style lang="less" scoped>
.pho {
	image {
		width: 246upx;
		height: 246upx;
		margin-right: 6upx;
	}
	image:nth-child(3n + 0) {
		margin-right: 0;
	}
}
.nophotodetail {
	width: 100%;
	text-align: center;
	font-size: 28upx;
	color: #999;
	line-height: 200upx;
}
</style>
